<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="utf-8">
    <title>新增分支</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/js/layui/css/layui.css}"  media="all" />
    <link rel="stylesheet" th:href="@{/css/public.css}"  media="all" />
    <style>
        .allAnswers{
            width: 80%;
        }
        .allDelete{
            position: absolute;
            top: 0;
            right:5%;
        }
        #oneToOneanswerSpan{
            color: green;
        }
    </style>
</head>
<body style="-webkit-backface-visibility: hidden;">
<div style="width:100%;-webkit-backface-visibility: hidden;">
    <form class="layui-form layui-row" style="text-align: center;" >
        <div class="layui-row layui-col-space10" style="text-align: center;position: absolute;top: 10px;left: 0px;bottom: 50px;overflow-y: auto;overflow-x: hidden;width: 100%">
            <div class="layui-form-item magt3">
                <label class="layui-form-label">分支名称:</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" placeholder="请输入分支名称" autocomplete="off" class="layui-input"
                           required th:value="${customCustomerAnswerType?.name}">
                </div>
            </div>
            <div class="layui-form-item magt3">
                <label class="layui-form-label">关键字:</label>
                <div class="layui-input-block" id="keywordBox" style="text-align: left;">
                    <input type="text" id="addKeyword"  placeholder="请输入关键字，多个关键词请用回车分割" autocomplete="off" class="layui-input"/>
                    <input id="keywords" name="keyworlds" type="hidden" lay-verify="required" />
                    <div id="keywordDiv"><span id="keywordColor">匹配到该分支的关键词</span></div>
                </div>
            </div>
            <div class="layui-form-item magt3" >
                <label class="layui-form-label">问法:</label>
                <div id="oneToOneanswerDiv"  style="text-align: left">
                    <a href="javascript:void(0)" id="oneToOneanswer" onclick="addAnswer('')"><span id="oneToOneanswerSpan">+&nbsp;添加问法</span></a>
                </div>
                <div class="layui-input-block" >
                    <textarea  placeholder="请输入分支问法" id="contentTxtArea" class="allAnswers layui-textarea"  lay-verify="required" ></textarea>
                </div>
            </div>

            <!--储存答案-->
            <input id="content" name="content" type="hidden" >

            <div class="layui-form-item"  style="display: none" >
                <input type="text" name="id" th:value="${customCustomerAnswerType?.id}" value="0" />
            </div>

            <div class="layui-form-item"  style="display: none" >
                <input type="text" name="flowId" th:value="${flowId}" value="0" />
            </div>

            <div class="layui-form-item"  style="display: none" >
                <input type="text" name="stepId" th:value="${stepId}" value="0" />
            </div>
        </div>
        <div style="position:absolute;left: 0px;bottom: 0px; width: 100%;height: 50px;background-color: #f2f2f2;padding: 0px;display: none">
            <button type="button" class="layui-btn" lay-submit lay-filter="add" style="width: 100px;float: right;margin-top: 7px;margin: 5px 5px;">保存</button>
            <button type="button" class="layui-btn"  id="cancel"  style="width: 100px;margin-top: 7px;background-color: #b2b2b2;float: right;margin: 5px 5px;" >取消</button>
        </div>
    </form>
</div>
<script th:inline="javascript">
    const baseUrl = [[${#servletContext.contextPath}]];
    var customCustomerAnswerType = [[${customCustomerAnswerType}]];
</script>
<script type="text/javascript"   th:src="@{/js/jquery-1.7.2.min.js}"></script>
<script type="text/javascript"   th:src="@{/js/layui/layui.js}"></script>
<script type="text/javascript"   th:src="@{/js/page/flow/config/saveOrUpdateCustomerAnswerWay.js}"></script>
<script type="text/javascript"   th:src="@{/js/page/utils.js}"></script>
<script th:inline="javascript">
    if (customCustomerAnswerType != undefined && customCustomerAnswerType != null) {
        console.log(customCustomerAnswerType);
        window.onload = loadCustomCustomerAnswerType; //页面载入完毕执行函数
    }
    function loadCustomCustomerAnswerType() {
        if (customCustomerAnswerType != null && customCustomerAnswerType != undefined) {
            if (customCustomerAnswerType.keyworlds!=undefined && customCustomerAnswerType.keyworlds != "") {
                var answerTypeArray = customCustomerAnswerType.keyworlds.split(",");
                $.each(answerTypeArray,function (idx, val) {
                    loadKeyWorlds(val)
                });
            }
            if (customCustomerAnswerType.contentStr!=undefined && customCustomerAnswerType.contentStr != "") {
                var answerTypeArray = customCustomerAnswerType.contentStr.split(",");
                if (answerTypeArray != undefined && answerTypeArray.length > 0) {
                    $("#contentTxtArea").html(answerTypeArray[0]);
                    answerTypeArray.splice(0, 1);
                }
                $.each(answerTypeArray,function (idx, val) {
                    addAnswer(val);
                });
                setanswerArray();
            }
        }
    }
</script>
</body>
</html>